<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%--
	JSTL:标准标签库,+EL表达式以后在JSP页面上不准写java代码
 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<title>订单列表 - 用户中心</title>
		<%@ include file="/common/include/title.jsp" %>
		<!-- 引入js文件的时候要注意顺序 -->
		<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>
	</head>
	<body>
		<%-- 静态包含
			因为在做第二个页面的时候每个页面的头,脚,都一样,所以将重复的代码单独放到一个文件中
		 --%>
		<%@ include file="/common/include/header.jsp" %>
		<div class="container-fluid">
			<div class="row">
				<div class="col-sm-10 col-sm-offset-1 main">
					<h2 class="sub-header">订单列表</h2>
					<form action="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderList" method="post" class="form-inline">
						<div class="form-group">
							<label for="keyword">关键字:</label>
							<input type="text" name="keyword" value="${requestScope.keyword }" class="form-control">
							<label for="keyword">状态:</label>
							<select name="status" class="form-control">
								<option value="">请选择</option>
								<option value="0" ${requestScope.status == '0' ? 'selected' : '' }>下单</option>
								<option value="10" ${requestScope.status == '10' ? 'selected' : '' }>进行中</option>
								<option value="20" ${requestScope.status == '20' ? 'selected' : '' }>已还车</option>
								<option value="30" ${requestScope.status == '30' ? 'selected' : '' }>已付款</option>
								<option value="40" ${requestScope.status == '40' ? 'selected' : '' }>报修</option>
							</select>
							<label for="email">创建时间:</label>
							<input type="text" name="st" value="${requestScope.st}" readonly="true" class="form-control"
								onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
								class="Wdate" />
							
							<input type="text" name="ed" value="${requestScope.ed}" readonly="true" class="form-control"
								onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
								class="Wdate" />
							<input type="submit" class="btn btn-primary"
								value="搜索">
							<a href="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderInsert"  class="btn btn-primary">添加</a>
						</div>
					</form>
					<div class="table-responsive">
						<table class="table table-striped">
							<thead>
								<tr>
									<th width="50">序号</th>
									<th width="80">用户Id</th>
									<th width="80">自行车表Id</th>							
									<th width="90">名称</th>
									<th width="110">开始时间</th>
									<th width="110">结束时间</th>
									<th width="90">耗时</th>
									<th width="50">总价格</th>
									<th width="80">报修类型</th>
									<th width="50">状态</th>
									<th width="110">注册时间</th>
									<th width="110">更新时间</th>
									<th width="130">操作</th>
								</tr>
							</thead>
							<tbody>
								<%-- 循环
									items:容器,resList,一定是reqeust.setAttribute(放值)
									var:临时变量,o
									i : stat
									
									List resList = null ; 
									for(int i = 0 ; i < resList.size(); i ++)
									{
										Object o = resList.get(i);
									}
								 --%>
								<c:forEach items="${requestScope.orderList }" var="order" varStatus="stat">
									<tr>
										<td>${stat.count }</td>
										<td>${order.usersId }</td>
										<td>${order.bikeId }</td>
										<td>${order.name }</td>
										<td><fmt:formatDate value="${order.startTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td><fmt:formatDate value="${order.endTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td>${order.consumeTime }</td>
										<td>${order.totalPrice }</td>
										<td>${order.repairContent }</td>															
										<td>
											<%-- 判断 --%>
											<c:choose>
												<c:when test="${order.status == 0}">
													下单
												</c:when>
												<c:when test="${order.status == 10}">
													进行中
												</c:when>
												<c:when test="${order.status == 20}">
													已还车
												</c:when>
												<c:when test="${order.status == 30}">
													已付款
												</c:when>
												<c:when test="${order.status == 40}">
													报修
												</c:when>
											</c:choose>
										</td>
										<td><fmt:formatDate value="${order.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td><fmt:formatDate value="${order.updateTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td>
											<a href="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderUpdate&aid=${order.id}"  class="btn btn-primary">更新</a>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
	
						<form id="usersListPageForm"
							action="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderList" method="post">
							<%--
								为了搜索+分页好使,在分页的时候每次都带上查询条件
							 --%>
							<input type="hidden" name="keyword" value="${requestScope.keyword }">
							<input type="hidden" name="status" value="${requestScope.status }">
							<input type="hidden" name="st" value="${requestScope.st }">
							<input type="hidden" name="ed" value="${requestScope.ed }">
							<nav>
								<ul class="pager">
									<li><a href="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderList&currentPage=1&pageSize=${requestScope.pageInfoUtil.pageSize }&keyword=${requestScope.keyword }&status=${requestScope.status }&st=${requestScope.st }&ed=${requestScope.ed }"><span>首页</span></a></li>
									<li><a href="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderList&currentPage=${requestScope.pageInfoUtil.prePage }&pageSize=${requestScope.pageInfoUtil.pageSize }&keyword=${requestScope.keyword }&status=${requestScope.status }&st=${requestScope.st }&ed=${requestScope.ed }"><span>上一页</span></a></li>
									<li><a href="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderList&currentPage=${requestScope.pageInfoUtil.nextPage }&pageSize=${requestScope.pageInfoUtil.pageSize }&keyword=${requestScope.keyword }&status=${requestScope.status }&st=${requestScope.st }&ed=${requestScope.ed }"><span>下一页</span></a></li>
									<li><a href="${pageContext.request.contextPath }/back/OrdersBackServlet?method=orderList&currentPage=${requestScope.pageInfoUtil.totalPage }&pageSize=${requestScope.pageInfoUtil.pageSize }&keyword=${requestScope.keyword }&status=${requestScope.status }&st=${requestScope.st }&ed=${requestScope.ed }"><span>尾页</span></a></li>
									<li>共${requestScope.pageInfoUtil.totalPage }页,共${requestScope.pageInfoUtil.totalRecord }条</li>
									<li>第<input type="text" id="currentPage" name="currentPage"
										value="${requestScope.pageInfoUtil.currentPage }" size="5" maxlength="5" />页
									</li>
									<li><input type="text" id="pageSize" name="pageSize"
										value="${requestScope.pageInfoUtil.pageSize }" size="5" maxlength="5" /></li>
									<li><input type="submit" value="GO" class="btn btn-primary" /></li>
								</ul>
							</nav>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!-- 提示信息 -->
		<div class="container">
			<div class="col-sm-8 col-sm-offset-1"></div>
		</div>
		<%-- 包含一下脚 --%>
		<%@ include file="/common/include/footer.jsp" %>
	</body>
</html>